# -*- coding:utf-8 -*-
"""
app entrance

启动方式 1:python main.py  (默认启动方式 mobile3_agri会以default的值做为启动参数)
        2:python main.py --mobile3_agri=testing (mobile3_agri参数会以testing做为启动参数)
        3:python main.py --mobile3_agri=production (mobile3_agri参数会以production做为启动参数)
"""

from tornado.options import define, options
from tornado.ioloop import IOLoop
from tornado import web

define("app", default='develop', help="", type=str)
define("port", default=2017, help="run on the given port", type=int)
# 该代码务必放在导入其它from,import的代码前面,如从16行到21的import一定要放到该句的下面
options.parse_command_line()

from settings import APPLICATION_SETTINGS as SETTINGS
from urls import URLS

app = web.Application(URLS, **SETTINGS)

if __name__ == "__main__":
    # app.listen(settings.PORT, xheaders=True)
    app.listen(options.port, xheaders=True)
    IOLoop.current().start()
